<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>后台 - 编辑管理员</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="__PUBLIC__/Admin/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/Admin/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/Admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="__PUBLIC__/Admin/css/animate.min.css" rel="stylesheet">
    <link href="__PUBLIC__/Admin/css/style.min862f.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal" method="post" action="{:U('System/nodesEdit')}" name="signupForm" id="signupForm" enctype="multipart/form-data">
                        <input type="hidden" name="id" value="{$info.id}" />
                        <div class="form-group">
                            <label class="col-sm-2 control-label">节点名称</label>
                            <div class="col-sm-6">
                                <input type="text" name="nav_name" id="username" value="{$info.nav_name}" placeholder="输入节点名称" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">控制器名称</label>
                            <div class="col-sm-6">
                                <input type="text" name="controller" id="controller" value="{$info.controller}" placeholder="输入控制器名称" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">方法名</label>
                            <div class="col-sm-6">
                                <input type="text" name="function" id="function" value="{$info.function}" placeholder="输入方法名称" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">父节点</label>
                            <div class="col-sm-6">
                                <select name = "pid" class="form-control m-b ">
                                    <if condition="$info.pid eq 0">
                                        <option value="0" <eq name = "info.pid" value="0">selected</eq> >父节点</option>
                                        <else/>
                                        <foreach name="navList " item="vo">
                                            <option value="{$vo.id}" <eq name="vo.id" value="$info.pid">selected</eq> >{$vo.title_show}{$vo.nav_name}</option>
                                        </foreach>
                                    </if>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit">保存内容</button>
                                <!--<a class="btn btn-danger" href="{:U('System/nodes')}">取消</a>-->
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="__PUBLIC__/Admin/js/jquery.min.js?v=2.1.4"></script>
<script src="__PUBLIC__/Admin/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__PUBLIC__/Admin/js/content.min.js?v=1.0.0"></script>
<script src="__PUBLIC__/Common/js/ajaxForm.js"></script>
<script src="__PUBLIC__/Common/layer/layer.js"></script>
<script>
    $(function(){
        $('#signupForm').ajaxForm({
            beforeSubmit: checkForm,
            success: complete,
            dataType: 'json'
        });
        function checkForm(){
            if( '' == $.trim($('#username').val())){
                layer.alert('输入用户名', {icon: 5}, function(index){
                    layer.close(index);
                    $('#username').focus();
                });
                return false;
            }
        }
        function complete(data){
            if(data.status==1){
                $('.btn-primary').attr('disabled','disabled');
                layer.msg(data.info, function(index){
                    layer.close(index);
                    window.location.href=data.url;
                });
            }else{
                layer.msg(data.info);
                return false;
            }
        }
    });
</script>
<script>
    function backpic(picurl){
        $("#img0").attr("src",picurl);
        $("input[name='file0']").val("");
        $("input[name='oldcheckpic']").val(picurl);
    }
    $("#file0").change(function(){
        var objUrl = getObjectURL(this.files[0]) ;
        console.log("objUrl = "+objUrl) ;
        if (objUrl) {
            $("#img0").attr("src", objUrl) ;
        }
    }) ;

    function getObjectURL(file) {
        var url = null ;
        if (window.createObjectURL!=undefined) {
            $("#oldcheckpic").val("nopic");
            url = window.createObjectURL(file) ;
        } else if (window.URL!=undefined) {
            $("#oldcheckpic").val("nopic");
            url = window.URL.createObjectURL(file) ;
        } else if (window.webkitURL!=undefined) {
            $("#oldcheckpic").val("nopic");
            url = window.webkitURL.createObjectURL(file) ;
        }
        return url ;
    }
</script>
</body>

</html>